import cv2
import numpy as np


def test_zero_kernel_behavior():
    # 创建测试图像
    img = np.random.randint(0, 255, (10, 10), dtype=np.uint8)
    print("原始图像:")
    print(img)

    # 创建全零卷积核
    zero_kernel = np.zeros((3, 3), dtype=np.uint8)
    print("\n全零卷积核:")
    print(zero_kernel)

    # 测试腐蚀
    try:
        eroded = cv2.erode(img, zero_kernel)
        print("腐蚀操作成功")
        print("腐蚀结果:")
        print(eroded)
    except Exception as e:
        print(f"腐蚀操作失败: {e}")

    # 测试膨胀
    try:
        dilated = cv2.dilate(img, zero_kernel)
        print("膨胀操作成功")
        print("膨胀结果:")
        print(dilated)
    except Exception as e:
        print(f"膨胀操作失败: {e}")


test_zero_kernel_behavior()